package cn.structure.edp;

import cn.structure.ClassEntity;
import cn.structure.MethodEntity;

import java.util.Objects;

public class AbstractInterface extends EdpEntity {
    private ClassEntity abstractor;
    private MethodEntity operation;

    public AbstractInterface(ClassEntity abstractor, MethodEntity operation) {
        super();
        this.abstractor = abstractor;
        this.operation = operation;
    }

    public ClassEntity getAbstractor() {
        return abstractor;
    }

    public void setAbstractor(ClassEntity abstractor) {
        this.abstractor = abstractor;
    }

    public MethodEntity getOperation() {
        return operation;
    }

    public void setOperation(MethodEntity operation) {
        this.operation = operation;
    }

    public enum Role {
        abstractor, operation
    }

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder("AbstractInterface{\n\t");
        sb.append(super.toString());
        sb.append("\n\t\"abstractor\":")
                .append(abstractor);
        sb.append(",\n\t\"operation\":")
                .append(operation);
        sb.append("\n}");
        return sb.toString();
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        if (!super.equals(o)) return false;
        AbstractInterface that = (AbstractInterface) o;
        return Objects.equals(abstractor, that.abstractor) &&
                Objects.equals(operation, that.operation);
    }

    @Override
    public int hashCode() {
        return Objects.hash(super.hashCode(), abstractor, operation);
    }
}
